/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lucava.metamodel.uspeed;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import lucava.metamodel.uspeed.visitor.IElementVisitor;

/**
 *
 * @author glenn
 */
public class ClassElement extends NamedElement {

    /**
     * Lites des classes étendues.
     */
    protected ArrayList<String> extendedClasses = new ArrayList<String>();
    /**
     * Liste des classes implémentés.
     */
    protected ArrayList<String> implementedClasses = new ArrayList<String>();
    /**
     * Liste des attributes de la classe.
     */
    protected ArrayList<AttributeElement> attributes = new ArrayList<AttributeElement>();
    /**
     * Liste des méthode de la classes.
     */
    protected ArrayList<MethodElement> methods = new ArrayList<MethodElement>();
    /**
     * Listes des relations (associations).
     */
    protected ArrayList<RelationElement> relations = new ArrayList<RelationElement>();
    /**
     * Boolean pour le modifier Abstract.
     */
    protected Boolean isAbstract = false;
    /**
     * Liste des stéréotypes à appliquer à la classe.
     */
    private Set<String> stereotypes = new HashSet<String>();

    public Boolean isAbstract() {
        return isAbstract;
    }

    public void setAbstract(Boolean isAbstract) {
        this.isAbstract = isAbstract;
    }

    public ArrayList<String> getExtendedClasses() {
        return extendedClasses;
    }

    public void setExtendedClasses(ArrayList<String> extendedClasses) {
        this.extendedClasses = extendedClasses;
    }

    public ArrayList<String> getImplementedClasses() {
        return implementedClasses;
    }

    public void setImplementedClasses(ArrayList<String> implementedClasses) {
        this.implementedClasses = implementedClasses;
    }

    public ArrayList<AttributeElement> getAttributes() {
        return attributes;
    }

    public void setAttributes(ArrayList<AttributeElement> attributes) {
        this.attributes = attributes;
    }

    public ArrayList<MethodElement> getMethods() {
        return methods;
    }

    public void setMethods(ArrayList<MethodElement> methods) {
        this.methods = methods;
    }

    public void setStereotype(String stereo) {
        this.stereotypes.add(stereo);
    }

    public Set<String> getStereotypes() {
        return this.stereotypes;
    }

    public void addMethod(MethodElement method) {
        this.methods.add(method);
    }

    public void addAttribute(AttributeElement attr) {
        this.attributes.add(attr);
    }

    public void addRelation(RelationElement rel) {
        this.relations.add(rel);
    }

    public void addExtendedClass(String targetClassName) {
        this.extendedClasses.add(targetClassName);
    }

    public void addImplementedInterface(String targetInterfaceName) {
        this.implementedClasses.add(targetInterfaceName);
    }

    @Override
    public void accept(IElementVisitor visitor) {
        visitor.enterClass(this);

        Iterator<AttributeElement> attrIt = attributes.iterator();
        while (attrIt.hasNext()) {
            attrIt.next().accept(visitor);
        }

        Iterator<RelationElement> relIt = relations.iterator();
        while (relIt.hasNext()) {
            relIt.next().accept(visitor);
        }

        Iterator<MethodElement> methIt = methods.iterator();
        while (methIt.hasNext()) {
            methIt.next().accept(visitor);
        }

        visitor.leaveClass(this);
    }
}
